package com.example.mobile2021606127cxz0401;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private boolean fan = true;
    private int img = 0;
    int[] image = {R.drawable.line1,R.drawable.line2,R.drawable.line3,R.drawable.line4,R.drawable.line5,R.drawable.line6};
    private ImageView imageView;
    private Button button;
    private Button button2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        imageView = (ImageView) findViewById(R.id.iv);
        button = (Button) findViewById(R.id.btn_main_on);
        button2 = (Button) findViewById(R.id.btn_main_off);
    }

    public void OffClick(View view) {
        imageView.setImageResource(R.drawable.light_off);
    }

    public void OnClick(View view) {
        imageView.setImageResource(R.drawable.light_on);
    }

    public void OnOffClick(View view) {
        if (fan) {
            imageView.setImageResource(R.drawable.fan_on);
            fan = false;
        } else {
            imageView.setImageResource(R.drawable.fan_off);
            fan = true;
        }

//        imageView.setImageResource(image[++img % image.length]);
    }

    public void NextClick(View view) {
        imageView.setImageResource(image[++img % image.length]);

    }
}